package com.google.code.pathlet.eshop;


import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;
 
public class JettyRunner 
{

	public final static int PORT = 8080;
 
    public static void main(String[] args) throws Exception {
        
        Server server = new Server(PORT);
        
        WebAppContext context = new WebAppContext();
        context.setResourceBase("webapp");
        context.setContextPath("/eshop");
        context.setParentLoaderPriority(true);
        
        
        // Jetty uses memory-mapped files to buffer static content, which causes the file-locking in Windows. 
        // Try setting useFileMappedBuffer for DefaultServlet to false.
        DefaultServlet defaultServlet = new DefaultServlet();
        ServletHolder holder = new ServletHolder(defaultServlet);
        holder.setInitParameter("useFileMappedB‌​uffer", "false");
        context.addServlet(holder, "/");
        context.addServlet(holder, "*.js");
        context.addServlet(holder, "*.html");
        context.addServlet(holder, "*.htm");

 
        server.setHandler(context);
 
        server.start();
        server.join();


    }
}